{extend name="default/template/base_index"/}

{block name="area_header"}
    <link rel="stylesheet" type="text/css" media="all" href="__CSS__/wxshop.css">
    <link type="text/css" rel="stylesheet" src="__CDN__/jquery-uploadify/3.2.1/uploadify.css"/>
    <script type="text/javascript" src="__CDN__/jquery-uploadify/3.2.1/jquery.uploadify.min.js"></script>
    <script type="text/javascript" src="__CDN__/jquery-validation/1.13.1/localization/messages_zh.min.js"></script>

{/block}

{block name="area_body"}
    {include file="default/Widget/topbar" /}
    <div class="admin-main container-fluid">
        {include file="default/Widget/left" /}
        <div class="admin-main-content">
            {include file="default/Widget/breadcrumb" /}
            <h4>当前店铺: <strong>{$store.name}</strong></h4>
            <!-- 过滤\查询按钮 -->
            <div class="filter-controls">
                <!-- 日期查询 -->
                <form action="{:url('Freight/index')}" method="post" class="form-inline">
                    <input type="hidden" name="store_id" value="{$store_id}"/>
                    <div class="form-group">
                        <label>商品状态</label>
                        <label class="radio-inline">
                            <input type="radio" name="onshelf" value="1" class="onshelf"
                            {eq name="onshelf" value="1"}checked="checked"{/eq}
                            />已上架
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="onshelf" value="0" class="onshelf"
                            {eq name="onshelf" value="0"}checked="checked"{/eq}
                            />未上架
                        </label>
                    </div>
                    <div class="form-group">
                        <label>商品名称</label>
                        <input type="text" name="name" class="form-control input-sm" value="{$name}"
                               placeholder="请输入商品名称"/>
                    </div>
                    <button type="submit" class="btn btn-default btn-sm" id="searchFormSubmit"><i
                            class="fa fa-search"></i>{:L('BTN_SEARCH')}
                    </button>
                </form>
            </div>
            <!-- 操作按钮 -->
            <div class="btn-controls">
                <div class="form-group">
                    <a class="btn btn-primary btn-sm" href="{:url('FreightTemplate/index')}"><i
                            class="fa fa-plus"></i>运费模版管理</a>
                </div>
                <div class="form-group">
                    <select id="freight_template" name="template_id"
                            class="form-control input-short  input-sm selectitem">
                        <option value="0">请选择运费模版</option>
                        {volist name="freight_template" id="vo"}
                            <option value="{$vo.id}">{$vo.name}</option>
                        {/volist}
                    </select>
                </div>

                <div class="form-group">
                    <a class="confirm ajax-post btn btn-primary btn-sm" href="{:url('Freight/save')}"
                       target-form="selectitem"><i class="fa fa-plus"></i>批量应用运费模版</a>
                </div>

            </div>
            <table class="table table-striped table table-hover  table-condensed">
                <thead>
                <tr>
                    <th width="180px;"><input type="checkbox" class="selectall" onclick="myUtils.selectall(this,'.selectitem');"/>ID
                    </th>
                    <th width="500px;">商品名称</th>
                    <th width="380px;">运费模版</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {empty name="list"}
                    <tr>
                        <td colspan="5" class="text-center">{:L('NO_DATA')}</td>
                    </tr>
                    {else/}
                    {volist name="list" id="vo"}
                        <tr>
                            <td>
                                <input type="checkbox" value="{$vo.id}" name="ids[]" class="selectitem"/>{$vo.id}
                            </td>
                            <td class="text-ellipsis">{$vo.name}<br/>
                            </td>
                            <td>
                                <form class="select_{$vo.id}">
                                    <input name="p_id" type="hidden" value="{$vo.id}">
                                    <select id="template_id" name="template_id"
                                            class="form-control input-short input-sm col-md-6 col-lg-6">
                                        <option value="0">请选择运费模版</option>
                                        {volist name="freight_template" id="vo1"}
                                            <option value="{$vo1.id}"
                                            {eq name="vo1.id" value="$vo.template_id"}selected{/eq}
                                            >{$vo1.name}</option>
                                        {/volist}
                                    </select>
                                </form>
                            </td>
                            <td>
                                <a target-form="select_{$vo.id}" class="ajax-post btn btn-primary btn-sm"
                                   href="{:url('Freight/save')}"><i class="fa fa-save"></i>应用运费模版</a>
                            </td>
                        </tr>
                    {/volist}
                {/empty}
                </tbody>
            </table>
            <div>{$show}</div>

        </div>
        <!-- END admin-main-content -->
    </div>
    <!-- END admin-main-->
{/block}

{block name="area_footer"}
    <script type="text/javascript">
        $(function () {
            $(".onshelf").click(function () {
                $("#searchFormSubmit").click();
            })
        })
    </script>
{/block}